Skip to content

[inworld] Pre-open WebSocket TTS context on LLM response start#4013

Open
ianbbqzy wants to merge 1 commit intopipecat-ai:mainfrom
inworld-ai:ian/prewarm-context-inworld-v2
Open

[inworld] Pre-open WebSocket TTS context on LLM response start#4013
ianbbqzy wants to merge 1 commit intopipecat-ai:mainfrom
inworld-ai:ian/prewarm-context-inworld-v2

Conversation

@ianbbqzy
Copy link
Contributor

Summary

  • Pre-opens the Inworld TTS context on the server when LLMFullResponseStartFrame arrives, overlapping server-side context creation with sentence aggregation time
  • Makes _send_context idempotent so run_tts skips the redundant create if the context was already prewarmed
  • Cleans up unused prewarmed contexts on new turns and disconnect to avoid orphaned contexts

Motivation

Without prewarming, context creation happens inside run_tts — after sentence aggregation completes — putting the server-side setup time on the TTFB critical path. By sending the context config as soon as the LLM turn starts, the server can allocate resources in parallel with text aggregation.

Testing performed

  • Pipecat WebSocket TTFB benchmark passes shows a 30ms improvement for 50pct latency
  • Pipecat quickstart voice bot works e2e

@ianbbqzy ianbbqzy force-pushed the ian/prewarm-context-inworld-v2 branch from fa27151 to dfe5fec Compare March 12, 2026 22:35
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 10.52632% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pipecat/services/inworld/tts.py 10.52% 17 Missing ⚠️
Files with missing lines Coverage Δ
src/pipecat/services/inworld/tts.py 24.89% <10.52%> (-0.59%) ⬇️

... and 17 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@filipi87 filipi87 self-requested a review March 13, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant